<template>
  <div>
      <h2 style="text-align: center;">缴费列表</h2>
      <el-table
              :data="tableData.slice((currentPage-1)*pagesize,currentPage*pagesize)"
              >
          <el-table-column
                  label="日期"
                  prop="date"
                  align="center"
          >
          </el-table-column>
          <el-table-column
                  label="姓名"
                  prop="name">
          </el-table-column>
          <el-table-column
                  label="身份证号"
                  prop="idCard">
          </el-table-column>
          <el-table-column
                  label="费用"
                  prop="pay">
          </el-table-column>
          <el-table-column label="操作" width="180" align="center">

              <template #default="scope">

                  <el-button type="text" icon="el-icon-lx-rechargefill" class="red"
                             @click="handlePay(scope.$index, scope.row)">收款</el-button>
              </template>
          </el-table-column>
      </el-table>
      <center>
          <el-pagination
                  @size-change="handleSizeChange"
                  @current-change="handleCurrentChange"
                  :current-page="currentPage"
                  :page-sizes="[5, 10, 20, 40]"
                  :page-size="pagesize"
                  layout="total, sizes, prev, pager, next, jumper"
                  :total="tableData.length"
          >
          </el-pagination>
      </center>
      <el-dialog   v-model="dialogFormVisible" width="410px" >
          <el-form :model="form">
              <el-form-item label="应付款:" >
                  <el-input v-model="form.pay"  readonly="readonly" autocomplete="off" style="width: 300px;float: right"></el-input>
              </el-form-item>
              <el-form-item label="实付款:" >
                  <el-input v-model="form.real_pay" autocomplete="off" style="width: 300px;float: right"></el-input>
              </el-form-item>
              <el-form-item label="应找回:" >
                  <el-input v-model="form.change" readonly="readonly" autocomplete="off" v style="width: 300px;float: right"></el-input>
              </el-form-item>
          </el-form>
          <div slot="footer"  class="dialog-footer">
              <center><el-button @click="dialogFormVisible = false">取 消</el-button>
                  <el-button type="primary" @click="Change">收款</el-button>
                  <el-button type="primary" @click="dialogFormVisible = false">确 定</el-button></center>
          </div>
      </el-dialog>
  </div>
</template>

<script>
    export default {
        name: "PayList",
        data() {
            return {
                tableData: [{
                    date: '2016-05-02',
                    name: '李刚',
                    idCard:'4423698562458',
                    pay: '13135'
                }, {
                    date: '2016-05-04',
                    name: '华强',
                    idCard:'4423698562458',
                   pay: '15464'
                }, {
                    date: '2016-05-01',
                    name: '陈浩南',
                    idCard:'12546',
                    pay: '92'
                }, {
                    date: '2016-05-03',
                    name: '山鸡',
                    idCard:'4423698562458',
                    pay: '64648'
                }],
                currentPage:1, //初始页
                pagesize:5,
                dialogFormVisible: false,
                form: {
                    id:'',
                    pay:'',
                    real_pay:'',
                    change:''
                },
            }
        },
        methods: {
            handlePay(index, row) {
                console.log(row);
                this.form= row;
                this.dialogFormVisible = true;
            },
            handleSizeChange: function (size) {
                this.pagesize = size;
                console.log(this.pagesize)  //每页下拉显示数据
            },
            handleCurrentChange: function(currentPage){
                this.currentPage = currentPage;
                console.log(this.currentPage)  //点击第几页
            },
            Change(){
                this.form.change=this.form.real_pay-this.form.pay;
            }
        },
    }
</script>

<style scoped>
 .red{
     color: red;
 }
</style>